#pragma once

#include <QtWidgets/QPushButton>
#include <QtWidgets/QLabel>
#include <QtWidgets/QWidget>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QGroupBox>
#include <QtNetwork/QUdpSocket>
#include <QtGui/QValidator>

class UDPSocket:public QWidget
{
public:
	UDPSocket(QString ip,int port, QWidget* parent = nullptr);

private:
    QPushButton * btn_send = nullptr;
    QGridLayout* mainLayout = nullptr,
        * top_layout = nullptr,
        * bottom_layout = nullptr,
        * center_layout = nullptr,
        * below_bottom_layout = nullptr;
    QGroupBox* centerBox = nullptr, * topBox = nullptr, * bottomBox = nullptr;
    QLabel* lb_port = nullptr;

    QTextEdit* t_receive = nullptr, * t_send = nullptr;
    QLineEdit* r_ip = nullptr, * r_port = nullptr;

    QUdpSocket* socket = nullptr;

    int port = 0;

    void initGUI();
    void SendMessage();
    void ReceivedMessage();
};

